/* @(#)FmmHeadlineNodeImpl.java
** 
** Copyright (C) 2012 by Steven D. Stamps
**
**             Trademarks & Copyrights
** Flywheel Management Science(TM), Flywheel Management Model(TM),
** Flywheel Story Editor(TM) and FlywheelMS(TM) are exclusive trademarks
** of Steven D. Stamps and may only be used freely for the purpose of
** identifying the unforked version of this software.  Subsequent forks
** may not use these trademarks.  All other rights are reserved.
**
** DecKanGL (Decorated Kanban Glyph Language) and TribKn (Tribal Knowledge)
** are also exclusive trademarks of Steven D. Stamps.  These may be used
** freely within the unforked FlywheelMS application and documentation.
** All other rights are reserved.
**
** gConGUI (game Controller Graphical User Interface) is an exclusive
** trademark of Steven D. Stamps.  This trademark may be used freely
** within the unforked FlywheelMS application and documentation.
** All other rights are reserved.
**
** Trademark information is available at
** <http://www.flywheelms.com/trademarks>
**
** Flywheel Management Science(TM) is a copyrighted body of management
** metaphors, governance processes, and leadership techniques that is
** owned by Steven D. Stamps.  These copyrighted materials may be freely
** used, without alteration, by the community (users and developers)
** surrounding this GPL3-licensed software.  Additional copyright
** information is available at <http://www.flywheelms.org/copyrights>
**
**              GPL3 Software License
** This program is free software: you can use it, redistribute it and/or
** modify it under the terms of the GNU General Public License, version 3,
** as published by the Free Software Foundation. This program is distributed
** in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
** even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
** PURPOSE.  See the GNU General Public License for more details. You should
** have received a copy of the GNU General Public License, in a file named
** COPYING, along with this program.  If you cannot find your copy, see
** <http://www.gnu.org/licenses/gpl-3.0.html>.
*/

package com.flywheelms.library.fmm.node.impl.headline;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;

import android.graphics.Bitmap;

import com.flywheelms.library.R;
import com.flywheelms.library.deckangl.enumerator.DecoratorCanvasLocation;
import com.flywheelms.library.deckangl.enumerator.WorkStateColor;
import com.flywheelms.library.deckangl.glyph.DecKanGlGlyph;
import com.flywheelms.library.deckangl.glyph.NounDefinition;
import com.flywheelms.library.deckangl.interfaces.DecKanGlDecorator;
import com.flywheelms.library.fmm.deckangl.DecoratorChildFractals;
import com.flywheelms.library.fmm.deckangl.DecoratorCompletion;
import com.flywheelms.library.fmm.deckangl.DecoratorFacilitationIssue;
import com.flywheelms.library.fmm.deckangl.DecoratorFacilitator;
import com.flywheelms.library.fmm.deckangl.DecoratorFlywheelCommitment;
import com.flywheelms.library.fmm.deckangl.DecoratorGovernance;
import com.flywheelms.library.fmm.deckangl.DecoratorParentFractals;
import com.flywheelms.library.fmm.deckangl.DecoratorStory;
import com.flywheelms.library.fmm.deckangl.DecoratorStrategicCommitment;
import com.flywheelms.library.fmm.deckangl.DecoratorWorkTaskBudget;
import com.flywheelms.library.fmm.deckangl.DecoratorWorkTeam;
import com.flywheelms.library.fmm.deckangl.FmmDecKanGlDictionary;
import com.flywheelms.library.fmm.deckangl.FmmDecKanGlNoun;
import com.flywheelms.library.fmm.node.NodeId;
import com.flywheelms.library.fmm.node.impl.FmmNodeImpl;
import com.flywheelms.library.fmm.node.interfaces.horizontal.FmmNodeHeadline;
import com.flywheelms.library.fmm.perspective.FmmPerspective;
import com.flywheelms.library.gcg.treeview.node.TreeNodeTargetObject;

public abstract class FmmHeadlineNodeImpl extends FmmNodeImpl
		implements FmmNodeHeadline, TreeNodeTargetObject, FmmDecKanGlNoun {
	
	private static final long serialVersionUID = 1L;
	private transient DecKanGlGlyph decKanGlGlyph;
	private String headline = "";
	protected HashMap<FmmPerspective, NodeCompletionSummary> nodeCompletionSummaryMap;
	public final ArrayList<FmmPerspective> perspectiveList = new ArrayList<FmmPerspective>();

	public FmmHeadlineNodeImpl(NodeId aNodeId) {
		super(aNodeId);
	}

	protected void initializeNodeCompletionSummaryMap() {
		this.nodeCompletionSummaryMap = new HashMap<FmmPerspective, NodeCompletionSummary>();
	}

	public void updateNodeCompletionSummary(FmmPerspective anFmmPerspective, NodeCompletionSummary aNodeSummary) {
	}
	
	public void updateAllNodeSummaries() {
		// iterate through node summary map
	}
	
	protected class NodeCompletionSummary implements Serializable {
		
		private static final long serialVersionUID = 1L;
		boolean showNodeSummary = false;
		String summaryPrefix = "";
		int summaryDrawableResourceId = R.drawable.empty_bitmap;
		String summarySuffix = "";
		
		public NodeCompletionSummary() {
			// TODO Auto-generated constructor stub
		}
		public String getSummaryPrefix() {
			return this.summaryPrefix;
		}
		public void setSummaryPrefix(String aSummaryPrefix) {
			this.summaryPrefix = aSummaryPrefix;
		}
		public int getSummaryDrawableResourceId() {
			return this.summaryDrawableResourceId;
		}
		public void setSummaryDrawableResourceId(int aSummaryDrawableResourceId) {
			this.summaryDrawableResourceId = aSummaryDrawableResourceId;
		}
		public String getSummarySuffix() {
			return this.summarySuffix;
		}
		public void setSummarySuffix(String summarySuffix) {
			this.summarySuffix = summarySuffix;
		}
		public boolean isShowNodeSummary() {
			return this.showNodeSummary;
		}
		public void setShowNodeSummary(boolean showNodeSummary) {
			this.showNodeSummary = showNodeSummary;
		}
		
	}
	
	@Override
	public Bitmap getDecKanGlBitmap() {
		return getDecKanGlGlyph().getDecoratedNounBitmap();
	}

	@Override
	public String getHeadline() {
		return this.headline;
	}

	@Override
	public void setHeadline(String headline) {
		this.headline = headline;
	}
	
	public HashMap<FmmPerspective, NodeCompletionSummary> getNodeSummaryMap() {
		if(this.nodeCompletionSummaryMap == null) {
			initializeNodeCompletionSummaryMap();
		}
		return this.nodeCompletionSummaryMap;
	}

	@Override
	public boolean hasNodeSummary(FmmPerspective anFmmPerspective) {
		NodeCompletionSummary theNodeSummary = getNodeSummaryMap().get(anFmmPerspective);
		return theNodeSummary == null ? false : theNodeSummary.isShowNodeSummary();
	}

	@Override
	public String getNodeSummaryPrefix(FmmPerspective anFmmPerspective) {
		NodeCompletionSummary theNodeSummary = getNodeSummaryMap().get(anFmmPerspective);
		return theNodeSummary == null ? "" : theNodeSummary.getSummaryPrefix();
	}

	@Override
	public int getNodeSummaryDrawableResourceId(FmmPerspective anFmmPerspective) {
		NodeCompletionSummary theNodeSummary = getNodeSummaryMap().get(anFmmPerspective);
		return theNodeSummary == null
				? R.drawable.empty_bitmap
				: theNodeSummary.getSummaryDrawableResourceId();
	}

	@Override
	public String getNodeSummarySuffix(FmmPerspective anFmmPerspective) {
		NodeCompletionSummary theNodeSummary = getNodeSummaryMap().get(anFmmPerspective);
		return theNodeSummary == null ? "" : theNodeSummary.getSummarySuffix();
	}

	@Override
	public WorkStateColor getDecKanGlWorkStateColor() {
		return WorkStateColor.GRAY;  // "placeholder" implementation - SDS
	}

	@Override
	public HashMap<DecoratorCanvasLocation, DecKanGlDecorator> getDecKanGlDecoratorMap() {
		HashMap<DecoratorCanvasLocation, DecKanGlDecorator> decKanGlDecoratorMap =
				new HashMap<DecoratorCanvasLocation, DecKanGlDecorator>();
		decKanGlDecoratorMap.put(
				FmmDecKanGlDictionary.getInstance().getTribKn(FmmDecKanGlDictionary.tribKn_GOVERNANCE).getLogicalCanvasLocation(),
				getDecoratorGovernance() );
		decKanGlDecoratorMap.put(
				FmmDecKanGlDictionary.getInstance().getTribKn(FmmDecKanGlDictionary.tribKn_FACILITATION_ISSUE).getLogicalCanvasLocation(),
				getDecoratorFacilitationIssue() );
		decKanGlDecoratorMap.put(
				FmmDecKanGlDictionary.getInstance().getTribKn(FmmDecKanGlDictionary.tribKn_FACILITATOR).getLogicalCanvasLocation(),
				getDecoratorFacilitator() );
		decKanGlDecoratorMap.put(
				FmmDecKanGlDictionary.getInstance().getTribKn(FmmDecKanGlDictionary.tribKn_PARENT_FRACTALS).getLogicalCanvasLocation(),
				getDecoratorParentFractals() );
		decKanGlDecoratorMap.put(
				FmmDecKanGlDictionary.getInstance().getTribKn(FmmDecKanGlDictionary.tribKn_CHILD_FRACTALS).getLogicalCanvasLocation(),
				getDecoratorChildFractals() );
		decKanGlDecoratorMap.put(
				FmmDecKanGlDictionary.getInstance().getTribKn(FmmDecKanGlDictionary.tribKn_STRATEGIC_COMMITMENT).getLogicalCanvasLocation(),
				getDecoratorStrategicCommitment() );
		decKanGlDecoratorMap.put(
				FmmDecKanGlDictionary.getInstance().getTribKn(FmmDecKanGlDictionary.tribKn_FLYWHEEL_COMMITMENT).getLogicalCanvasLocation(),
				getDecoratorFlywheelCommitment() );
		decKanGlDecoratorMap.put(
				FmmDecKanGlDictionary.getInstance().getTribKn(FmmDecKanGlDictionary.tribKn_WORK_TASK_BUDGET).getLogicalCanvasLocation(),
				getDecoratorWorkTaskBudget() );
		decKanGlDecoratorMap.put(
				FmmDecKanGlDictionary.getInstance().getTribKn(FmmDecKanGlDictionary.tribKn_WORK_TEAM).getLogicalCanvasLocation(),
				getDecoratorWorkTeam() );
		decKanGlDecoratorMap.put(
				FmmDecKanGlDictionary.getInstance().getTribKn(FmmDecKanGlDictionary.tribKn_STORY).getLogicalCanvasLocation(),
				getDecoratorStory() );
		decKanGlDecoratorMap.put(
				FmmDecKanGlDictionary.getInstance().getTribKn(FmmDecKanGlDictionary.tribKn_COMPLETION).getLogicalCanvasLocation(),
				getDecoratorCompletion() );
		return decKanGlDecoratorMap;
	}

	@Override
	public String getDecKanGlNounName() {
		return getNounDefinition().getName();
	}

	@Override
	public DecKanGlGlyph getDecKanGlGlyph() {
		if(this.decKanGlGlyph == null) {
			updateDecKanGlGlyph();
		}
		return this.decKanGlGlyph;
	}

	@Override
	public void updateDecKanGlGlyph() {
		this.decKanGlGlyph = FmmDecKanGlDictionary.getInstance().getDecKanGlGlyph(this);
	}

	@Override
	public DecKanGlGlyph getUpdatedDecKanGlGlyph() {
		updateDecKanGlGlyph();
		return this.decKanGlGlyph;
	}

	@Override
	public NounDefinition getNounDefinition() {
		if(this.decKanGlGlyph != null) {
			return getDecKanGlGlyph().getNounDefinition();
		}
		return FmmDecKanGlDictionary.getInstance().getNounDefinitionForName(this.getClass().getSimpleName());
	}

	@Override
	public DecoratorGovernance getDecoratorGovernance() {
		return DecoratorGovernance.GOVERNANCE_QUALITY_NOT_ENABLED;
	}

	@Override
	public DecoratorFacilitationIssue getDecoratorFacilitationIssue() {
		return DecoratorFacilitationIssue.FACILITATION_ISSUE_QUALITY_NOT_ENABLED;
	}

	@Override
	public DecoratorFacilitator getDecoratorFacilitator() {
		return DecoratorFacilitator.FACILITATOR_QUALITY_NOT_ENABLED;
	}

	@Override
	public DecoratorStrategicCommitment getDecoratorStrategicCommitment() {
		return DecoratorStrategicCommitment.COMMITMENT_QUALITY_NOT_ENABLED;
	}

	@Override
	public DecoratorFlywheelCommitment getDecoratorFlywheelCommitment() {
		return DecoratorFlywheelCommitment.COMMITMENT_QUALITY_NOT_ENABLED;
	}

	@Override
	public DecoratorParentFractals getDecoratorParentFractals() {
		return DecoratorParentFractals.PARENT_FRACTAL_QUALITY_NOT_ENABLED;
	}

	@Override
	public DecoratorChildFractals getDecoratorChildFractals() {
		return DecoratorChildFractals.CHILD_FRACTAL_QUALITY_NOT_ENABLED;
	}

	@Override
	public DecoratorWorkTaskBudget getDecoratorWorkTaskBudget() {
		return DecoratorWorkTaskBudget.BUDGET_QUALITY_NOT_ENABLED;
	}

	@Override
	public DecoratorWorkTeam getDecoratorWorkTeam() {
		return DecoratorWorkTeam.TEAM_QUALITY_NOT_ENABLED;
	}

	@Override
	public DecoratorStory getDecoratorStory() {
		return DecoratorStory.STORY_QUALITY_NOT_ENABLED;
	}

	@Override
	public DecoratorCompletion getDecoratorCompletion() {
		return DecoratorCompletion.COMPLETION_QUALITY_NOT_ENABLED;
	}
	
	@Override
	public boolean hasNodeQuality() {
		return true;
	}

	@Override
	public int getNodeQualityIndex() {
		return getDecKanGlGlyph().getNodeQualityIndex();
	}
	
	@Override
	public boolean isComplete() {
		return false;
	}
	
	/////////////////////////////////////////

}
